//
//  PersonCell.m
//  tcpoctest
//
//  Created by gump on 10/26/12.
//  Copyright (c) 2012 gump. All rights reserved.
//

#import "PersonCell.h"
#import "PublicFun.h"
#import <QuartzCore/QuartzCore.h>

@implementation PersonCell

@synthesize headImageView,nameLabel,sexicon,disLabel,ageLabel;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //        self.contentView.backgroundColor = [UIColor whiteColor];
        
        //头像
        CGRect headFrame = CGRectMake(6, (60 - 49)/2, 49, 49);
        headImageView = [[UIImageView alloc] initWithFrame:headFrame];
        headImageView.userInteractionEnabled = YES;
        headImageView.layer.cornerRadius = 5;
        headImageView.layer.masksToBounds = YES;
        [self.contentView addSubview:headImageView];
        
        //昵称
        nameLabel = [[UILabel alloc]initWithFrame:CGRectZero];
		nameLabel.backgroundColor = [UIColor clearColor];
		nameLabel.textColor = [UIColor colorWithRed:30/255.0 green:30/255.0 blue:30/255.0 alpha:1];
        nameLabel.highlightedTextColor = [UIColor whiteColor];
		nameLabel.font = CENTER_CELL_TITLE_FONT;
		nameLabel.textAlignment = UITextAlignmentLeft;
		[self.contentView addSubview:nameLabel];
        
        //性别图片
        sexicon = [[UIImageView alloc]initWithFrame:CGRectZero];
        [self.contentView addSubview:sexicon];
        
        //年龄
        ageLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        ageLabel.backgroundColor = [UIColor clearColor];
		ageLabel.textColor = [UIColor colorWithRed:73/255.0f green:73/255.0f blue:73/255.0f  alpha:1.0f] ;
		ageLabel.font = [UIFont systemFontOfSize:14];
		ageLabel.textAlignment = UITextAlignmentLeft;
        [self.contentView addSubview:ageLabel];
        
        //显示距离
        disLabel = [[UILabel alloc]initWithFrame:CGRectMake(230, 6, 80, 20)];
		disLabel.backgroundColor = [UIColor clearColor];
		disLabel.textColor = [UIColor colorWithRed:143/255.0f green:143/255.0f blue:143/255.0f  alpha:1.0f] ;
		disLabel.font = [UIFont systemFontOfSize:13];
		disLabel.textAlignment = UITextAlignmentLeft;
		[self.contentView addSubview:disLabel];
        
        
        //个人签名
        self.signLabel = [[UILabel alloc]initWithFrame:CGRectMake(64, 30, 230, 25)];
		self.signLabel.backgroundColor = [UIColor clearColor];
		self.signLabel.textColor = [UIColor colorWithRed:143/255.0f green:143/255.0f blue:143/255.0f  alpha:1.0f] ;
		self.signLabel.font = [UIFont systemFontOfSize:14];
		self.signLabel.textAlignment = UITextAlignmentLeft;
		[self.contentView addSubview:self.signLabel];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

#pragma mark - 自定义宽度
-(void)changeCellSize{
    CGSize constraint = CGSizeMake(220, 1000);//label宽度设为200，高度最多为1000
    CGSize theSize = [nameLabel.text sizeWithFont:CENTER_CELL_CONTENT_FONT
                                constrainedToSize:constraint
                                    lineBreakMode:NSLineBreakByCharWrapping];//根据文字的多少来设定行高
    

//    self.nameLabel.frame = CGRectMake(64, 2, theSize.width + 10, 30);//昵称的坐标
//    self.sexicon.frame = CGRectMake(64 + theSize.width + 18, 10, 14, 14);
//    self.ageLabel.frame = CGRectMake(64 + theSize.width + 35, 10, 24, 14);
    self.nameLabel.frame = CGRectMake(64, 2, theSize.width + 10, 30);//昵称的坐标
    self.sexicon.frame = CGRectMake(64 + theSize.width + 18, 10, 14, 14);
    self.ageLabel.frame = CGRectMake(64 + theSize.width + 38, 10, 24, 14);

    
    
}

@end